package org.summerframework.component.enums;

import org.summerframework.component.enums.annotation.EnumKind;
import org.summerframework.core.base.dto.BaseEnum;
import lombok.Getter;

/**
 * @author 石超
 * @version v1.0.0
 */
@Getter
@EnumKind("USE")
public enum UseEnum implements BaseEnum {
    NOT_USE(0, "未使用"),
    USE(1, "已使用");

    private Integer code;

    private String desc;

    public static UseEnum getInstance(Integer code) {
        if (code == null) return NOT_USE;
        for (UseEnum statusEnum : UseEnum.values()) {
            if (statusEnum.getCode().equals(code)) {
                return statusEnum;
            }
        }

        return NOT_USE;
    }

    @Override
    public boolean isType(Integer code) {
        return this.code.equals(code);
    }

    UseEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }
}
